﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using System.Web;
using Tomato.Helpers;

namespace Tomato.Authentication
{
    public class SessionAuthenticator
    {
        public static void SignIn(Controller controller, object data)
        {
            controller.Session["User"] = data;
        }

        public static bool IsSigneIn(Controller controller)
        {
            return controller.Session["User"] != null;
        }

        public static T GetSignInData<T>(Controller controller)
        {
            return (T)controller.Session["User"];
        }

        public static void SignOff(Controller controller)
        {
            HttpSessionStateBase session = controller.Session;
            session.Clear();
        }
    }
}
